<template>
  <div v-loading="detailInfoShow">
    <div class="requestAdd">
      <!-- 审核按钮 -->
      <div class="search-button">
        <!-- <el-button
          v-if="activeName == 'approval' && flowInfoList.length"
          @click="handleEvaluate()"
          class="btn save"
          ><el-icon class="icon" color="#fff"> <Comment /> </el-icon
          >评论</el-button
        > -->
        <el-button
          v-if="activeName == 'approval' && flowInfoList.length"
          @click="handlePrint()"
          v-print="prints"
          class="btn add"
          ><el-icon class="icon" color="#fff"> <Printer /> </el-icon
          >打印</el-button
        >
        <el-button
          v-if="
            activeName == 'nodswe' &&
            pagestatus == 'detail' &&
            requestForm.nextAudit.flowIntype == 2
          "
          class="btn"
          type="primary"
          style="width: 80px"
          @click="edit"
          plain
          >编辑</el-button
        >
        <el-button
          v-if="activeName == 'nodswe' && pagestatus == 'edit'"
          class="btn"
          type="primary"
          style="width: 80px"
          @click="detail"
          plain
          >返回</el-button
        >
        <el-button class="btn direction" @click="handleBack"
          ><el-icon class="icon" color="#fff"> <Back /> </el-icon
          >返回</el-button
        >
      </div>
      <!-- 内容区 -->
      <el-tabs
        type="border-card"
        v-model="activeName"
        @tab-change="activeNamechange"
      >
        <el-tab-pane label="基本信息" name="info">
          <el-collapse v-model="activeNames">
            <el-form
              :model="requestForm"
              ref="requestFormRef"
              :rules="queryRules"
              label-width="120px"
              v-enterToNext
              :disabled="pageType === 'detail' || pageType === 'check'"
            >
              <!-- 基础信息 -->
              <el-collapse-item name="1" class="transform-down">
                <template #title>
                  <span class="circle"></span>
                  <span class="collapse-title"
                    >{{
                      pageType == "detail" || pageType == "check "
                        ? ""
                        : pageType === "add"
                        ? "新增"
                        : "编辑"
                    }}非合同用印</span
                  >
                </template>
                <div class="request-info">
                  <el-row>
                    <!-- <el-col :span="6">
                  <el-form-item label="文件名称：" prop="nonContractSealName">
                    <el-input
                      style="width: 100%"
                      v-model="requestForm.nonContractSealName"
                      maxlength="50"
                      placeholder="请输入"
                    ></el-input>
                  </el-form-item>
                </el-col> -->

                    <el-col :span="6">
                      <el-form-item label="申请日期：" prop="applyTime">
                        <el-date-picker
                          v-model="requestForm.applyTime"
                          format="YYYY/MM/DD HH:mm:ss"
                          style="width: 100%"
                          class="search-input"
                          value-format="YYYY-MM-DD HH:mm:ss"
                          type="datetime"
                        />
                      </el-form-item>
                    </el-col>

                    <el-col :span="6">
                      <el-form-item label="经办人：" prop="userId">
                        <el-select
                          v-model="requestForm.userId"
                          placeholder="请选择"
                          clearable
                          filterable
                          class="search-input"
                          @change="handleUserChange"
                          value-key="userId"
                          placement="bottom-end"
                        >
                          <el-option disabled :value="null">
                            <div class="auto-top">
                              <span class="auto-item">人员姓名</span>
                              <span class="auto-item">联系方式</span>
                              <span class="auto-item">职位</span>
                              <span class="auto-item">部门</span>
                            </div>
                          </el-option>
                          <el-option
                            v-for="dict in userList"
                            :key="dict.userId"
                            :value="dict.userId"
                            :label="dict.nickName"
                          >
                            <div style="display: flex">
                              <div class="auto-item" :title="dict.nickName">
                                {{ dict.nickName }}
                              </div>
                              <div class="auto-item" :title="dict.phonenumber">
                                {{ dict.phonenumber ? dict.phonenumber : "--" }}
                              </div>
                              <div class="auto-item" :title="dict.postName">
                                {{ dict.postName ? dict.postName : "--" }}
                              </div>
                              <div class="auto-item" :title="dict.fullDeptName">
                                {{
                                  dict.fullDeptName ? dict.fullDeptName : "--"
                                }}
                              </div>
                            </div>
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="申请部门：">
                        <el-input
                          disabled
                          v-model="requestForm.deptName"
                          placeholder="自动获取"
                          clearable
                          class="search-input"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item
                        label="文件编号："
                        prop="nonContractSealCode"
                      >
                        <el-input
                          style="width: 100%"
                          v-model="requestForm.nonContractSealCode"
                          maxlength="50"
                          placeholder="请输入"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="文件类型：" prop="nonContractType">
                        <el-select
                          v-model="requestForm.nonContractType"
                          placeholder="请选择"
                          clearable
                          style="width: 100%; height: 100%"
                        >
                          <el-option
                            v-for="dict in moduleStatusList"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          />
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col
                      :span="6"
                      v-if="[0].includes(requestForm.nonContractType)"
                    >
                      <el-form-item label="项目名称：" prop="projectId">
                        <el-select
                          v-model="requestForm.projectId"
                          placeholder="请选择"
                          clearable
                          filterable
                          class="search-input"
                        >
                          <el-option key="0" label="" value="" disabled>
                            <span style="float: left; color: #8492a6"
                              >项目编号</span
                            >
                            <span style="margin: 0 80px 0 100px; color: #8492a6"
                              >项目名称</span
                            >
                            <span
                              style="
                                margin: 0 50px 0 0px;
                                color: #8492a6;
                                font-size: 13px;
                              "
                              >项目类别</span
                            >
                            <span
                              style="
                                float: right;
                                color: #8492a6;
                                font-size: 13px;
                              "
                              >项目类型</span
                            >
                          </el-option>
                          <el-option
                            v-for="item in projectList"
                            :key="item.projectId"
                            :label="item.projectName"
                            :value="item.projectId"
                          >
                            <span style="float: left; color: #8492a6">{{
                              item.projectCode
                            }}</span>
                            <span
                              style="
                                display: inline-block;
                                width: 125px;
                                margin: 0 10px 0 23px;
                                color: #8492a6;
                                white-space: nowrap;
                                overflow: hidden;
                                text-overflow: ellipsis;
                              "
                              :title="item.projectName"
                              >{{ item.projectName }}</span
                            >
                            <span style="float: right; font-size: 13px">
                              {{ item.projectTypeName }}
                            </span>
                            <span
                              style="
                                float: right;
                                margin: 0 75px 0 0px;
                                font-size: 13px;
                              "
                            >
                              {{ item.projectCategoryName }}
                            </span>
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col
                      :span="6"
                      v-if="[0].includes(requestForm.nonContractType)"
                    >
                      <el-form-item
                        label="项目类型："
                        prop="projectCategoryName"
                      >
                        <el-input
                          disabled
                          v-model="requestForm.projectCategoryName"
                          placeholder="自动获取"
                          clearable
                          class="search-input"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col
                      :span="6"
                      v-if="[0].includes(requestForm.nonContractType)"
                    >
                      <el-form-item label="项目编号：" prop="projectCode">
                        <el-input
                          disabled
                          v-model="requestForm.projectCode"
                          placeholder="自动获取"
                          clearable
                          class="search-input"
                        />
                      </el-form-item>
                    </el-col>

                    <el-col :span="6">
                      <el-form-item label="印章归属：" prop="companyId">
                        <el-input
                          disabled
                          v-model="requestForm.companyName"
                          placeholder="请输入"
                          clearable
                          class="search-input"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="印章类型：" prop="sealType">
                        <el-select
                          v-model="requestForm.sealType"
                          placeholder="请选择"
                          clearable
                          style="width: 100%; height: 100%"
                        >
                          <el-option
                            v-for="dict in deliveryStatusList"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          />
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item
                        label="收函单位类型："
                        prop="receivingUnitType"
                      >
                        <el-select
                          v-model="requestForm.receivingUnitType"
                          placeholder="请选择"
                          clearable
                          style="width: 100%; height: 100%"
                        >
                          <el-option
                            v-for="dict in receivingUnitList"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          />
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label=" 收函单位：" prop="receivingUnit">
                        <el-input
                          style="width: 100%"
                          v-model="requestForm.receivingUnit"
                          maxlength="50"
                          placeholder="请输入"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="文件用途：" prop="documentUse">
                        <el-input
                          v-model="requestForm.documentUse"
                          placeholder="请输入文件用途"
                          clearable
                          maxlength="50"
                          style="width: 100%; height: 100%"
                          class="search-input"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col
                      :span="6"
                      v-if="[0].includes(requestForm.nonContractType)"
                    >
                      <el-form-item label="运营文件" prop="fileType">
                        <el-select
                          v-model="requestForm.fileType"
                          placeholder="请选择"
                          clearable
                          style="width: 100%; height: 100%"
                        >
                          <el-option
                            v-for="dict in fileTypeList"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          />
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col
                      :span="6"
                      v-if="[1].includes(requestForm.nonContractType)"
                    >
                      <el-form-item label="行政文件" prop="fileType">
                        <el-select
                          v-model="requestForm.fileType"
                          placeholder="请选择"
                          clearable
                          style="width: 100%; height: 100%"
                        >
                          <el-option
                            v-for="dict in fileTypeList"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          />
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col
                      :span="6"
                      v-if="[2].includes(requestForm.nonContractType)"
                    >
                      <el-form-item label="财务文件" prop="fileType">
                        <el-select
                          v-model="requestForm.fileType"
                          placeholder="请选择"
                          clearable
                          style="width: 100%; height: 100%"
                        >
                          <el-option
                            v-for="dict in fileTypeList"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          />
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="用印份数：" prop="numberOfCopies">
                        <el-input
                          type="Number"
                          v-model="requestForm.numberOfCopies"
                          placeholder="请输入"
                          clearable
                          :max="99"
                          class="search-input"
                        >
                          <template #append>份</template>
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="是否归档：" prop="archive">
                        <el-radio-group v-model="requestForm.archive">
                          <el-radio :label="1">是，需要归档</el-radio>
                          <el-radio :label="0">否，无需归档</el-radio>
                        </el-radio-group>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6" v-if="[1].includes(requestForm.archive)">
                      <el-form-item
                        label="应归档份数："
                        prop="pigeonholeNumber"
                      >
                        <el-input
                          v-model="requestForm.pigeonholeNumber"
                          type="Number"
                          placeholder="请输入"
                          clearable
                          :max="99"
                          class="search-input"
                        >
                          <template #append>份</template></el-input
                        >
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="6">
                      <el-form-item label="用印申请：" prop="contractAccessory">
                        <Upload
                          :fileList="requestForm.contractAccessory"
                          :isFull="true"
                          :limit="10"
                          limitation="ciculation"
                          :showButton="true"
                          @success="(result) => uploadSuccess(result)"
                          @deleteFile="(result) => uploadRemove(result)"
                          :isCanDelete="
                            pageType == 'detail' || pageType == 'check'
                              ? false
                              : true
                          "
                          :disabled="
                            pageType == 'detail' || pageType == 'check'
                          "
                        />
                        <!-- accept=".jpg,.png" -->
                      </el-form-item>
                    </el-col>
                  </el-row>
                </div>
              </el-collapse-item>
            </el-form>
          </el-collapse>
        </el-tab-pane>
        <el-tab-pane label="审批日志" name="approval">
          <div id="print-iframe" v-if="flowInfoList.length">
            <!-- 步骤栏 -->
            <div :class="printFlag ? 'steps-print-box' : 'steps-box'" style="height:100%;">
              <el-steps
                direction="vertical"
                :class="flowInfoList.length > 7 ? 'BigSteps' : 'SmallSteps'"
                :active="flowingStep"
                finish-status="success"
              >
                <el-step v-for="(item, index) in flowInfoList" :key="index">
                  <template #title>
                    <div class="steps-top">
                      <div :title="item.name" style="width: 200px">
                        {{ item.name }}
                      </div>
                      <span class="steps-time">{{ item.createTime }}</span>
                    </div>
                  </template>
                  <template #description>
                    <div
                      class="steps-box-info"
                      v-if="item.auditEmpList && item.auditEmpList.length"
                    >
                      <div
                        v-for="(child, index) in item.auditEmpList"
                        :key="index"
                      >
                        <div class="ription">
                          {{ child.createUserName }} {{ child.resultName }}
                        </div>
                        <div class="ription" v-if="child.remark">
                          处理意见： {{ child.remark }}
                        </div>
                        <div
                          class="line"
                          v-if="index + 1 != item.auditEmpList.length"
                        ></div>
                      </div>
                    </div>
                  </template>
                </el-step>
              </el-steps>
            </div>
            <!-- 表格数据 -->
            <el-table
              v-if="false"
              :data="auditList"
              border
              :height="'100%'"
              :header-cell-style="{ 'text-align': 'center' }"
              sum-text=""
            >
              <!-- 操作模式 -->
              <el-table-column label="流程节点" prop="name" min-width="120">
              </el-table-column>
              <el-table-column
                label="审核人"
                prop="createUserName"
                min-width="120"
              >
              </el-table-column>
              <el-table-column
                label="审核时间"
                prop="createTime"
                min-width="120"
              >
              </el-table-column>
              <el-table-column
                label="审核意见"
                prop="resultName"
                min-width="120"
              >
              </el-table-column>
              <el-table-column label="审核备注" prop="remark" min-width="120">
              </el-table-column>
            </el-table>
          </div>

          <div v-else>暂无审核</div>
        </el-tab-pane>
        <el-tab-pane label="归档文档" name="nodswe">
          <Contractcustodian
            v-if="
              activeName == 'nodswe' && requestForm.archiveVo.flowIntype == 2
            "
            ref="ContractcustodianRef"
            @handleBack="handleBack"
            :requestForm="requestForm"
            :pagestatus="pagestatus"
          ></Contractcustodian>
          <Subapplicant
            v-if="
              activeName == 'nodswe' && requestForm.archiveVo.flowIntype == 1
            "
            @handleBack="handleBack"
            :requestForm="requestForm"
            :pagestatus="pagestatus"
          ></Subapplicant>
          <div
            v-if="
              activeName == 'nodswe' && requestForm.archiveVo.flowIntype == 0
            "
          >
            暂无归档
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <el-dialog
      :title="''"
      v-model="evaluateDialogShow"
      width="600px"
      append-to-body
    >
      <el-form-item label="评论内容：" label-width="90">
        <el-input
          style="width: 100%"
          v-model="evaluateInfo"
          placeholder=""
          type="textarea"
          rows="5"
          maxlength="500"
          clearable
        />
      </el-form-item>
      <template #footer>
        <div class="dialog-footer">
          <el-button
            style="color: #fff; background-color: rgba(67, 207, 124, 1)"
            @click="saveEvaluate()"
            >保存</el-button
          >

          <el-button style="background-color: #fff" @click="closeEvaluate()"
            >取 消</el-button
          >
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, provide, inject, onMounted, defineProps } from "vue";
import useUserStore from "@/store/modules/user";
import Upload from "@/components/Upload/index";
import { getUserListApi } from "@/api/information/customer";
import { getDictsApi } from "@/api/dict";
import { projectListRequest2 } from "@/api/purchase/request";
import { addEvaluateApi, getEvaluateListApi } from "@/api/pub.js";
import { getselectFolderList } from "@/api/seal/placeonfile";
import print from "vue3-print-nb";
import { nonConSealDeatil, selectAuditList } from "@/api/seal/circulation";
import { gettypeContract } from "@/api/seal/placeonfile";
import { ElMessage, ElMessageBox } from "element-plus";
import Contractcustodian from "./contractcustodian";
import Subapplicant from "./subapplicant";
import dayjs from "dayjs";
const route = useRoute();
const emit = defineEmits([
  // 客户新增组件显隐
  "circulationAddShow",
  // 更新客户新增组件显隐
  "update:circulationAddShow",
  // 刷新父组件表格数据
  "refreshList",
]);
//当前用户信息
const userStore = useUserStore();
const props = defineProps({
  // 操作类型
  pageType: {
    type: String,
    default: "add",
  },
});
// 详情加载效果
const detailInfoShow = ref(false);
const activeName = ref("info");
// 折叠栏默认展开
const activeNames = ref(["1", "2", "3"]);
// 客户表单引用
const requestFormRef = ref();
// 客户表单数据模板
const requestFormTemplate = {
  // nonContractSealName: "", //文件名称
  nonContractSealCode: "", //文件编号
  applyTime: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"), // 申请日期
  userId: null, //经办人
  // deptName: "", // 申请部门
  receivingUnit: "", // 	收函单位
  receivingUnitType: null, //收函单位类型
  projectId: null, //关联项目
  projectCategoryName: "", //项目类型
  projectCode: "", //项目编号
  organizationName: null, // 印章归属
  documentUse: "", // 	文件用途
  fileType: null, // 	运营文件|| 行政文件||财务文件
  sealType: null, // 	印章类型
  numberOfCopies: "", // 用印份数
  pigeonholeNumber: "", // 应归档份数
  contractAccessory: [], // 用印申请文件
  nonContractType: null, //模块类型(0:运营用印,1:行政用印,2:财务用印,3:研发用印)
  archive: 1,
  type: 0, //按钮类型0：保存；1；提交
};
const data = reactive({
  // 客户表单
  requestForm: JSON.parse(JSON.stringify(requestFormTemplate)),
  // 客户表单校验规则
  queryRules: {
    applyTime: [
      { required: true, message: "请选择申请日期", trigger: "change" },
    ],
    userId: [{ required: true, message: "请选择经办人", trigger: "change" }],
    organizationName: [
      { required: true, message: "请选择印章归属", trigger: "change" },
    ],
    archive: [{ required: true, message: "请选择", trigger: "change" }],
    projectId: [
      { required: true, message: "请选择项目名称", trigger: "change" },
    ],
    nonContractType: [
      { required: true, message: "请选择文件类型", trigger: "change" },
    ],
    fileType: [{ required: true, message: "请选择", trigger: "change" }],
    sealType: [
      { required: true, message: "请选择印章类型", trigger: "change" },
    ],
    // nonContractSealName: [
    //   { required: true, message: "请输入文件名称", trigger: "blur" },
    // ],
    nonContractSealCode: [
      { required: true, message: "请输入文件编号", trigger: "blur" },
    ],
    receivingUnit: [
      { required: true, message: "请输入收函单位", trigger: "blur" },
    ],
    receivingUnitType: [
      { required: true, message: "请选择收函单位类型", trigger: "change" },
    ],
    numberOfCopies: [
      { required: true, message: "请输入用印份数", trigger: "blur" },
      {
        validator: (rule, value, callback) => {
          if (value < 1 || value > 99) {
            callback(new Error("用印份数为0到99之间的整数"));
          } else {
            callback();
          }
        },
        trigger: "blur",
      },
    ],
    documentUse: [
      { required: true, message: "请输入文件用途", trigger: "blur" },
    ],
    pigeonholeNumber: [
      { required: true, message: "请输入应归档份数", trigger: "blur" },
      {
        validator: (rule, value, callback) => {
          if (value < 1 || value > 99) {
            callback(new Error("应归档份数为0到99之间的整数"));
          } else {
            callback();
          }
        },
        trigger: "blur",
      },
    ],
    contractAccessory: [
      { required: true, message: "请上传附件", trigger: "change" },
    ],
  },
  // 用户列表
  userList: [],
});
const { requestForm, queryRules, userList } = toRefs(data);
// 项目类型列表
// const kindList = ref([]);
// 项目名称列表
const projectList = ref([]);
// 组织列表
const organizationList = ref([]);
//文件类型列表
const fileTypeList = ref([]);
//印章类型列表
const deliveryStatusList = ref([]);
//收函单位类型列表
const receivingUnitList = ref([]);
//文件类型列表
const moduleStatusList = ref([]);
//审核进度列表数据
let auditList = ref([]);

//审核进度条数据
const flowInfoList = ref([]);
//当前进度
const flowingStep = ref(0);
// 评论
const evaluateDialogShow = ref(false);
// 评论内容
const evaluateInfo = ref("");
// 评论列表
const evaluateList = ref([]);
//打印点击
const handlePrint = () => {
  printFlag.value = true;
};
// 使用自定义指令
const vPrint = print;
const printFlag = ref(false);

let diskList = ref([]);
let options = [];

let pagestatus = ref("detail");

let ContractcustodianRef = ref(null);

let prints = {
  id: "print-iframe",
  popTitle: "配置页眉标题", // 打印配置页上方的标题
  extraHead: "", // 最上方的头部文字，附加在head标签上的额外标签，使用逗号分割
  preview: false, // 是否启动预览模式，默认是false
  previewTitle: "预览的标题", // 打印预览的标题
  previewPrintBtnLabel: "预览结束，开始打印", // 打印预览的标题下方的按钮文本，点击可进入打印
  zIndex: 20002, // 预览窗口的z-index，默认是20002，最好比默认值更高
  previewBeforeOpenCallback() {
    console.log("正在加载预览窗口！");
  }, // 预览窗口打开之前的callback
  previewOpenCallback() {
    console.log("已经加载完预览窗口，预览打开了！");
  }, // 预览窗口打开时的callback
  // 开始打印之前的callback
  beforeOpenCallback() {
    console.log("开始打印之前！");
  },
  openCallback() {
    console.log("执行打印了！");
  }, // 调用打印时的callback
  closeCallback() {
    console.log("关闭了打印工具！");
    printFlag.value = false;
  }, // 关闭打印的callback(无法区分确认or取消)
  clickMounted() {
    console.log("点击v-print绑定的按钮了！");
  },
  standard: "",
  extarCss: "",
};
// tab改变
const activeNamechange = (value) => {
  if (value == "nodswe") {
    if (requestForm.value.archiveVo.flowIntype == 2) {
      nextTick(() => {
        ContractcustodianRef.value.handlerdetail();
      });
    }
  }
};
// 处理评论按钮点击
const handleEvaluate = () => {
  evaluateDialogShow.value = true;
};
// 保存评论
const saveEvaluate = async () => {
  if (!evaluateInfo.value) return ElMessage.info("请输入评论内容！");
  const data = {
    businessId: requestForm.value.nonContractSealId,
    content: evaluateInfo.value,
    modelType: 13,
  };
  const result = await addEvaluateApi(data);
  if (result.code === 200) {
    ElMessage.success(result.msg);
    evaluateDialogShow.value = false;
    evaluateInfo.value = "";
    getEvaluateList();
  }
};

// 关闭评论弹窗
const closeEvaluate = () => {
  evaluateDialogShow.value = false;
  evaluateInfo.value = "";
};
// 获取评价列表
const getEvaluateList = async () => {
  const data = {
    businessId: requestForm.value.nonContractSealId,
    modelType: 13,
  };
  const result = await getEvaluateListApi(data);
  evaluateList.value = result.data || [];
};
/**
 * @description: 处理人员选择
 * @param {Number} value 选择值
 */
const handleUserChange = (value) => {
  if (value) {
    const selectUser = userList.value.find((item) => item.userId === value);
    if (selectUser) {
      requestForm.value.deptName = selectUser.deptName;
    }
  } else {
    requestForm.value.deptName = "";
  }
};
/**
 * @description: 文件上传成功处理
 * @param {Object} response 文件信息
 */
function uploadSuccess(response) {
  requestForm.value.contractAccessory.push({ ...response, businessType: 30 });
}

/**
 * @description: 删除文件
 * @param {Number} index 当前文件索引
 */
function uploadRemove(index) {
  requestForm.value.contractAccessory.splice(index, 1);
}

const edit = () => {
  pagestatus.value = "edit";
};
const detail = () => {
  pagestatus.value = "detail";
};
provide("detail", detail);
/**
 * @description: 处理详情信息
 * @param {Number} id
 */
const handleDetailInfo = async (id) => {
  try {
    detailInfoShow.value = true;
    const res = await nonConSealDeatil({ nonContractSealId: id });
    if (res.code == 200) {
      requestForm.value = {
        ...res.data,
      };
      // 存在为null无法push场景
      if (!requestForm.value.contractAccessory) {
        requestForm.value.contractAccessory = [];
      }
    }
    const resAudit = await selectAuditList(id);
    console.log("resAudit", resAudit);
    auditList.value = resAudit.data;
    if (resAudit.data.length) {
      flowInfoList.value = resAudit.data;
      flowingStep.value = resAudit.data[0].flowingStep;
    }
    getEvaluateList();
    detailInfoShow.value = false;
  } catch (error) {
    detailInfoShow.value = false;
  }
};
/**
 * @description: 返回
 */
const handleBack = () => {
  if (props.pageType === "detail" || props.pageType === "check") {
    emit("update:circulationAddShow", false);
    requestForm.value = JSON.parse(JSON.stringify(requestFormTemplate));
  } else {
    ElMessageBox.confirm("确定返回上一级吗?以上数据未保存将会丢失!", "提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
      confirmButtonClass: "confirmBtnClass",
      cancelButtonClass: "cancelBtnClass",
    })
      .then(async () => {
        emit("update:circulationAddShow", false);
        requestForm.value = JSON.parse(JSON.stringify(requestFormTemplate));
      })
      .catch(() => {});
  }
};

/**
 * @description: 获取字典
 */
async function getDicts() {
  await getUserListApi({}).then((res) => {
    if (res.length > 0) {
      userList.value = res;
    }
  });
  // 项目列表
  await projectListRequest2({}).then((res) => {
    if (res) {
      projectList.value = res;
    }
  });
  //组织名称
  await getDictsApi("erp_party_units").then((res) => {
    if (res.code === 200) {
      organizationList.value = res.data;
    }
  });
  //印章类型
  await getDictsApi("erp_seal_type").then((res) => {
    if (res.code === 200) {
      deliveryStatusList.value = res.data;
    }
  });
  //文件类型
  await getDictsApi("erp_operate_file_type").then((res) => {
    if (res.code === 200) {
      fileTypeList.value = res.data;
    }
  });
  //收函单位类型
  await getDictsApi("erp_receiving_unit_type").then((res) => {
    if (res.code === 200) {
      receivingUnitList.value = res.data;
    }
  });
  //模块类型
  await getDictsApi("erp_non_contract_type").then((res) => {
    if (res.code === 200) {
      moduleStatusList.value = res.data;
    }
  });
  //云盘
  getselectFolderList({ type: 0 }).then((response) => {
    diskList.value = response.data;
  });
}
/**
 * @description: 获取字典下拉
 */
const gettypeContractdata = async () => {
  await gettypeContract({
    dictType: "erp_archive_file_type",
    type: 1,
  }).then((res) => {
    if (res.code == 200) {
      options = res.data;
    }
  });
};
onMounted(() => {
  getDicts();
  gettypeContractdata();
});
defineExpose({
  handleDetailInfo,
});
</script>

<style lang="scss" scoped>
.requestAdd {
  padding: 20px 20px;
  width: 100%;
  height: 100%;
  .request-info {
    padding: 20px 20px 5px 20px;
    background-color: #f0f0f0;
    margin: 10px 0;
  }

  .contact-info {
    padding-top: 20px;
  }

  :deep(.el-table) {
    th.el-table__cell {
      background: #f8f8f8 !important;
    }
  }

  :deep(.el-date-editor.el-input, .el-date-editor.el-input__wrapper) {
    width: 268px !important;
    height: 34px !important;
  }

  .search-input {
    width: 268px;
    height: 34px;
  }

  .image-content {
    width: 100%;
    line-height: 0px;
    overflow: auto;
  }
}

.auto-top {
  width: 100%;
  position: absolute;
  top: 0px;
  display: flex;
  font-weight: bold;
}

.auto-item {
  width: 125px;
  text-align: left;
  white-space: nowrap;
  /* 禁止换行 */
  overflow: hidden;
  /* 隐藏超出部分 */
  text-overflow: ellipsis;
  /* 使用省略号表示超出部分 */
}

.el-autocomplete .el-autocomplete-suggestion {
  max-height: 200px;
  /* 设置最大高度 */
  overflow-y: auto;
  /* 超出高度时显示滚动条 */
}
:deep(.el-form-item--default) {
  margin-bottom: 22px;
}
:deep(.el-form-item--default .el-form-item__error) {
  padding-top: 5px;
}
:deep(.el-form-item--default) {
  margin-bottom: 22px;
}
:deep(.el-form-item--default .el-form-item__error) {
  padding-top: 5px;
}
:deep(.el-step__head.is-success) {
    color: #3399ff !important;
    border-color: #3399ff;
    position: relative;
  }
  :deep(.el-step__title.is-success) {
    color: #3399ff !important;
  }
.steps-time {
  font-size: 14px;
  color: #666666;
  margin-left: 300px;
}
.steps-box-info {
  margin: 30px 0;
  padding: 10px;
  width: 630px;
  min-height: 56px;
  border: 1px solid #e6e6e6;
  .ription {
    margin-bottom: 10px;
  }
  .line {
    width: 100%;
    border: 1px solid #e6e6e6;
    margin-bottom: 10px;
  }
}
.steps-top {
  display: flex;
}
</style>
